<%--
Created by IntelliJ IDEA.
User: 骆鹏
Date: 2017/7/27
Time: 11:03
To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <title><fmt:message code="doc.th.AlreadyDocument"/></title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="/css/officialDocument/officialDocument.css">
<link rel="stylesheet" type="text/css" href="/css/main/theme3/fontawesome5.min.css"/>
    <link rel="stylesheet" href="/lib/layer/skin/default/layer.css">
    <link rel="stylesheet" href="/lib/pagination/style/pagination.css">
    <link rel="stylesheet" href="/lib/laydate/need/laydate.css">
    <link rel="stylesheet" href="/css/base/base.css?20201106.1">
	<link rel="stylesheet" type="text/css" href="/css/global.css"/>
    <%--<link rel="stylesheet" href="/css/base.css">--%>
    <link rel="stylesheet" type="text/css" href="/css/main/theme3/fontawesome5.min.css"/>

    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="/js/base/tablePage.js"></script>
    <script src="/lib/layer/layer.js?20201106"></script>
    <script src="/js/base/base.js?20191025.1"></script>
    <script src="/lib/laydate/laydate.js"></script>
    <script src="/lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
    <style>
        .pagediv .page-top-inner-layer table th {
            font-size: 14px;
            line-height: 30px;
            background-color: #e8f4fc;
        }
        .pagediv .page-top-inner-layer table tr {
            border-color: #e8f4fc;
        }
        .pagediv .page-top-outer-layer::before {
            content: '';
            display: block;
            width: 100%;
            height: 5px;
            background-color: #2a7ddc;
            border-radius: 3px;
        }
        table thead {
            background: white;
            line-height: 40px;
            border-bottom: 1px #dddddd solid;
            font-size: 14pt;
            color: #2f5c8f;
            font-weight: bold;
            border: 0px;
        }
        .Query.fl:hover {
            background-color: #418adf;
        }
        .fl input{
            border: 1px solid #ccc;
			width:200px;
        }
        #pageTbody tr{
            cursor: pointer;
        }
        
        .pagediv .page-bottom-outer-layer table td:nth-child(2){
            overflow: auto;
            white-space: inherit;
            text-overflow: clip;
        }
        .editAndDelete3,.editAndDelete4 {
            color: #e01919;
        }
        .wenhao{
            cursor: pointer;
        }
        table tr th{
            padding: 5px 4px!important;
        }
        .pagediv .page-top-inner-layer {
            height: 42px;
        }
        .pagediv .page-top-inner-layer table th{
            line-height: 30px;
        }
        /*已办发文列表操作按钮模板 复制到需要的页面文件中 开始*/

        .editAndDelete0,
        .editAndDelete1,
        .editAndDelete2,
        .editAndDelete3,
        .editAndDelete4,
        .editAndDelete5 {
            margin-right: 10px;
            margin-bottom: 5px;
            margin-top: 5px;
            font-size: 12px;
            height: 25px;
            line-height: 25px;
            padding: 0 6px;
            border-radius: 3px;
            background-color: #2b7edf;
            color: #fff !important;
        }


        /*只要修改content值*/
        /*查看：f865
          删除或者回收等：f2ed
          传阅：f5da
          转交：f4c6
          委托：f4c4
          催办：f7e4
          结束：f895
        */


        .editAndDelete0:before {
            content: "\f865";
        }
        .editAndDelete1:before {
            content: "\f865";
        }
        .editAndDelete2:before {
            content: "\f7e4";
        }
        .editAndDelete3:before {
            content: "\f2ed";
        }
        .editAndDelete4:before {
            content: "\f895";
        }
        .editAndDelete5:before {
            content: "\f2ed";
        }


        .editAndDelete0:before,
        .editAndDelete1:before,
        .editAndDelete2:before,
        .editAndDelete3:before,
        .editAndDelete4:before,
        .editAndDelete5:before {
            font-family: "Font Awesome 5 Pro";
            -webkit-font-smoothing: antialiased;
            -moz-osx-font-smoothing: grayscale;
            display: inline-block;
            font-style: normal;
            font-variant: normal;
            font-weight: 300;
            line-height: 1;
            margin-right: 4px;
        }
        /*已办发文列表操作按钮模板 复制到需要的页面文件中 结束*/
        /*.pagediv .page-top-inner-layer table thead th:nth-child(3),
        .pagediv .page-bottom-inner-layer table tr td:nth-child(3) {
            text-align: center;
        }*/
		.Query {
    margin-left: 10px;
}

    </style>
</head>
<body style="background-color:#fff">
<div class="headTop">
    <div class="headImg">
        <img src="/img/commonTheme/${sessionScope.InterfaceModel}/yibanfawen.png" alt="">
    </div>
    <div class="divTitle">
        <fmt:message code="doc.th.AlreadyDocument"/>
    </div>
</div>
<div style="margin: 0 auto;margin-top: 46px;height: 60px;width: 97%;" class="clearfix">
    <label class="fl" style="margin-top: 16px;display: none;">
        <span class="fl" style="margin-top: 5px;"><fmt:message code="doc.th.recordType"/>：</span>
        <select name="dispatchType" id="">
            <option value=""><fmt:message code="hr.th.PleaseSelect"/></option>
        </select>
    </label>

    <label class="fl clearfix" style="margin-top: 16px;margin-left: 10px;display: none;">
        <span class="fl" style="margin-top: 5px;" ><fmt:message code="global.lang.date"/>：</span>
        <label class="fl">
            <input type="text" name="printDate" placeholder="<fmt:message code="doc.th.enterDate"/>" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})"></label>

    </label>
    <label class="fl clearfix" style="margin-top: 16px" >
        <span class="fl" style="margin-top: 5px;"><fmt:message code="notice.th.title"/>：</span>
        <label class="fl"><input name="title" placeholder="请输入标题或者流水号"  type="text"></label>
        <button  type="button" class="Query fl g_button_z_2z g_button_z_select"><fmt:message code="global.lang.query"/></button>
    </label>

</div>

<div id="pagediv">

</div>

<script>
    function bzlct(e) {
        window.event.cancelBubble=true
        eventas = e;
        var aa = window.open('/flowSetting/processDesignToolTwo?flowId=' + e.attr('flowid') + '&rilwId=' + e.attr('runid'), '','height=700, width=1100, top=55,left=400, toolbar=no, menubar=no, scrollbars=yes , resizable=no,location=no, status=no');
    }
    var pageObj;
    window.onresize = function(){
        var screenwidth = document.documentElement.clientWidth;
        if(screenwidth > 1155){
            var nums = screenwidth*0.97;
            var sumwidth = screenwidth*0.97+'px';
        }else{
            var nums = 1120;
            var sumwidth = '1120px';
        }
       pageObj.configuration[0]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[1]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[2]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[3]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[4]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[5]['width'] = nums * 0.08 + 'px';
        pageObj.configuration[6]['width'] = nums * 0.08 + 'px';
        $('.page-top-outer-layer').css('width',sumwidth).find('table').css('width',sumwidth);
        for(var i=0;i< $('.page-top-outer-layer').find('th').length;i++){
            $('.page-top-outer-layer').find('th').eq(i).css('width',pageObj.configuration[i]['width']);
        }
        $('.page-bottom-outer-layer').css('width',sumwidth).find('.page-bottom-inner-layer').css('width',sumwidth).find('table').css('width',sumwidth);
        var table = $('.page-bottom-outer-layer .page-bottom-inner-layer table');
        for(var i=0;i<table.find('tr').length;i++){
            for(var j=0;j<table.find('tr').eq(i).find('td').length;j++){
                table.find('tr').eq(i).find('td').eq(j).css('width',pageObj.configuration[j]['width']);
            }
        }
    };

    var openRold=parent.opensload;
    $.ajax({
        url:'/getCompanyAll',
        type:'get',
        data:{},
        dataType:'json',
        success:function(res){
            var length = res.obj.length;
            var screenwidth = document.documentElement.clientWidth;
            if(screenwidth > 1155){
                var nums = screenwidth*0.97;
                var sumwidth = screenwidth*0.97+'px';
            }else{
                var nums = 1120;
                var sumwidth = '1120px';
            }
                var width1 = nums*0.068+'px';
			    var width2 = nums*0.092+'px';
			    var width3 = nums*0.08+'px';
			    var width4 = nums*0.08+'px';
			    var width5 = nums*0.08+'px';
			    var width7 = nums*0.08+'px';
			    var width8 = nums*0.08+'px';
            pageObj=$.tablePage('#pagediv',sumwidth,[
                {
                    width:width1,
                    title:'<fmt:message code="workflow.th.liushui"/>',
                    name:'runId'
                },
                {
                    width:width2,
                    title:'<fmt:message code="doc.th.DispatchHeader"/>',
                    name:'title',
                    selectFun:function (title,obj) {
                        if(obj.workLevel == 0||obj.workLevel == undefined){
                            var str = '<span style="color: green;">【普通】</span>';
                        }else if(obj.workLevel == 1){
                            var str = '<span style="color: red;">【紧急】</span>';
                        }else if(obj.workLevel == 2){
                            var str = '<span style="color: red;">【特急】</span>';
                        }
                        if(title!=undefined){
                            //return '<a href="javascript:;" class="title-xiangqing wenhao wenhao1">'+str+title+'</a>'
                            return '<a href="javascript:;" class="title-xiangqing wenhao wenhao1">'+title+'</a>'
                        }else {
                            return ""
                        }
                    }
                },
                {
                    width:width3,
                    title:'我经办的步骤',
                    name:'realPrcsId',
                    selectFun:function (step,obj) {
                        if(obj.prcsName == undefined){
                            var prcsName = '';
                        }else{
                            var prcsName = obj.prcsName;
                        }
                        if(obj.state1 == '已办结'){
                            var color = "red"; //37aa43
                        }else{
                            var color = '#2b7fe0'
                            // obj.state1 = '已转交，下一步办理中'
                        }
                        return '<a class="wenhao" style="cursor: pointer;" onclick="bzlct($(this))" runid="'+ obj.runId +'" flowid="'+ obj.flowId +'"><span><fmt:message code="workflow.th.First" />'+step+'<fmt:message code="workflow.th.step" />:'+prcsName+'</span>';

                    }
                },
                {
                    width:width4,
                    title:'<fmt:message code="doc.th.Scholar"/>',
                    name:'createrName',
                    selectFun:function (createrName,obj) {
                        if(createrName){
                            return createrName
                        }else {
                            return ""
                        }
                    }
                },
                {
                    width:width5,
                    title:'<fmt:message code="attend.th.CurrentStep"/>',
                    name:'curUserId',
                    selectFun:function (curUserId,obj) {
                        if(obj.state == '已结束'){
                            return '<span style="color:red"><fmt:message code="meet.th.IsOver" /></span>'
                        }else{
                            if(obj.state2 == 1){
                                return '<a class="wenhao" id="a_thisStep" style="cursor: pointer;color:green" onclick="bzlct($(this))" step="'+ obj.step +'" runid="'+ obj.runId +'" flowid="'+ obj.flowId +'"><fmt:message code="adding.th.Concurrent" /><br><fmt:message code="adding.th.Concurrent" /></a>';
                            }else{
                                if(obj.currentPeople == undefined){
                                    obj.currentPeople = '';
                                }
                                return '<a class="wenhao" id="a_thisStep" style="cursor: pointer;color:green" onclick="bzlct($(this))" step="'+ obj.step +'" runid="'+ obj.runId +'" flowid="'+ obj.flowId +'">'+ obj.bz +'<br>'+ obj.currentPeople +'</a>';
                            }
                        }
                    }
                },
                {
                    width:width7,
                    title:'<fmt:message code="workflow.th.Settlingtime"/>',
                    name:'deliverTime',
                    selectFun:function (name) {
                        if(name){
                            return name
                        }else {
                            return ''
                        }
                    }
                },
                {
                    width:width8,
                    title:'<fmt:message code="notice.th.operation"/>',
                }
            ],function (me) {
                me.data.printDate=$('[name="printDate"]').val();
                me.data.dispatchType=$('[name="dispatchType"]').val()
                me.data.title=$('[name="title"]').val()
                me.data.documentType=0;
                me.data.pageSize = 10;

                /***********公文模块智能开发，根据页面url中存在flowId传值判断******************/
                var flowId = $.GetRequest().flowId|| '';
                me.data.flowId=flowId;
                if(flowId != ''){
                    $('.divTitle').html('已阅');
                }
                //1显示  // 2不显示  //不写fn这个属性就是全显示
                me.init('/document/selOverDocSendOrReceive',[{name:'下发',fn:function (obj) {
                        var maps = obj.map.userid
                        if(length > 1 ){
                            if(obj.endTime!=undefined&&obj.endTime!='' && maps==access_token){
                                return 1
                            }else if(maps!=access_token && maps==undefined){
                                return 2
                            }
                        }else{
                            return 0
                        }
                    }},{
                    /*<fmt:message code="roleAuthorization.th.ViewDetails"/>查看详情*/
                    name:'查看',fn:function (obj) {
                        return 1
                    }
                },{
                    name:'传阅情况',fn:function(obj){
                        if(obj.viewUser== ","||obj.viewUser== ""){
                            return 0
                        }else {
                            return  1;
                        }
                    }
                },{
                    name:'<fmt:message code="roleAuthorization.th.TakeBack" />',fn:function(obj){
                        if(obj.prFlag=="4" || obj.branchCount!="0"){
                            return 0
                        }else {
                            return  1;
                        }
                    }
                },{
                    name:'传阅撤回',fn:function(obj){
                        if(obj.viewUser== ","||obj.viewUser== ""){
                            return 0
                        }else {
                            return  1;
                        }
                    }
                }])
            })

            $('.Query').click(function () {
                pageObj.data.page=1;
                pageObj.data.printDate=$('[name="printDate"]').val();
                pageObj.data.dispatchType=$('[name="dispatchType"]').val()
                pageObj.data.title=$('[name="title"]').val()
                pageObj.init();
            })

            //获取cookie里面的key值
            function getCookie(cookieName) {
                var strCookie = document.cookie;
                var arrCookie = strCookie.split("; ");
                for(var i = 0; i < arrCookie.length; i++){
                    var arr = arrCookie[i].split("=");
                    if(cookieName == arr[0]){
                        return arr[1];
                    }
                }
                return "";
            }
            var access_token = getCookie("userId")   //在cookie里面的key值

            $(document).on('click','.title-xiangqing',function (ev) {
                ev.stopPropagation()
                $(this).parents('tr').click();
            })

            $(document).on('click','.editAndDelete0',function (ev) {
                ev.stopPropagation()
                var obj=pageObj.arrs[$(this).attr('data-i')]
                layer.open({
                    title: '下发公文',
                    btn: ['<fmt:message code="global.lang.ok"/>', '<fmt:message code="depatement.th.quxiao"/>'],
                    area: ['600px', '400px'],
                    content: '<ul id="xiafagongwen" class="clearfix"></ul>',
                    success:function () {
                        $.get('/documentOrg/getCompanyAll',{locales:obj.id},function (json) {
                            if(json.flag){
                                var str='';
                                var arr=json.obj;
                                for(var i=0;i<arr.length;i++){
                                    str+='<li style="margin: 5px 10px;float: left">' +
                                        '<label><input style="vertical-align: middle" type="checkbox" value="'+arr[i].oid+'">'+arr[i].name+'</label></li>'
                                }
                                $('#xiafagongwen').html(str);
                            }
                        },'json')
                    },
                    yes:function (index) {
                        var transferReceiveOrg='';
                        $('#xiafagongwen li [type=checkbox]:checked').each(function (i,n) {
                            transferReceiveOrg+=$(this).val()+','
                        })
                        $.post('/documentOrg/save',{transferReceiveOrg:transferReceiveOrg,id:obj.id},function (json) {
                            if(json.flag){
                                $.layerMsg({content:'下发成功',icon:1})
                            }
                        },'json')
                    }
                })
            })



            $(document).on('click','.tr_click',function (ev) {
                var obj=pageObj.arrs[$(this).attr('data-i')]
                window.open('/workflow/work/workformPreView?flowId='+obj.flowId+'&flowStep='+obj.step+'' +
                    '&tabId='+obj.id+'&tableName='+obj.tableName+'&runId='+obj.runId+'&' +
                    'prcsId='+obj.realPrcsId+'&isNomalType=false&hidden=true', '', 'height=700, width=1100, top=55,left=400, toolbar=no, menubar=no, scrollbars=yes , resizable=no,location=no, status=no')
            })
            $(document).on('click','.editAndDelete3',function (ev) {
                ev.stopPropagation()
                var obj=pageObj.arrs[$(this).attr('data-i')]
                $.ajax({
                    type: "get",
                    url: "/workflow/work/workBack",
                    dataType: 'JSON',
                    data: {
                        prcsId: obj.step,
                        runId: obj.runId,
                        flowPrcs: obj.realPrcsId,
                        userId:obj.curUserId,
                        tabId:obj.id,
                        tableName:obj.tableName
                    },
                    success: function (res) {
                        if(res.flag){
                            $.layerMsg({content:'收回成功！',icon:1});
                            location.reload();
                        }else{
                            $.layerMsg({content:'收回失败！',icon:2});
                            location.reload();
                        }
                    }
                });
            })
            
            //鼠标悬浮当前步骤时，显示提示信息
    var tip_index
    $('#pagediv').on('mouseenter','#a_thisStep',function () {
        var that = this;
        $.get('/flowRun/stepStatus',{runId:$(this).attr('runid'),step:$(this).attr('step')},function (res) {
            // console.log(res)
            var data=res.obj
            var str=''
            data.forEach(function (v,i) {
                str+='<div>'+'<span>123123123'+v.userName+'</span>&nbsp;&nbsp;&nbsp;'+v.prcsFlag+'</div>'
            })
            tip_index=layer.tips(str,that, {
                tips: [1, '#3595CC'],
                time: 0
            });
        })
    });
    $('#pagediv').on('mouseleave','#a_thisStep',function () {
        layer.close(tip_index);
    });

            
            $(document).on('click','.editAndDelete2',function (ev) {
                ev.stopPropagation()
                var obj=pageObj.arrs[$(this).attr('data-i')]
                window.open('/ToBeReadController/ReadFileInfo?&runId='+obj.runId+'&prcsId='+obj.step+'&flowPrcs='+obj.realPrcsId);
            })
            $(document).on('click','.editAndDelete4',function (ev) {
                ev.stopPropagation()
                var obj=pageObj.arrs[$(this).attr('data-i')];
                $.layerConfirm({title:'传阅撤回',content:'确认将该公文传阅撤回吗？',icon:0,offset:"200px"},function(){
                    $.ajax({
                        type: "get",
                        url: "/ToBeReadController/withdrawFileRead",
                        dataType: 'JSON',
                        data: {
                            prcsId: obj.step,
                            runId: obj.runId,
                            flowPrcs: obj.realPrcsId,
                            tabId:obj.id,
                            tableName:obj.tableName,
                            flowId:obj.flowId
                        },
                        success: function (res) {
                            if(res.flag){
                                $.layerMsg({content:'传阅撤回成功！',icon:1});
                                pageObj.init();
                            }else{
                                $.layerMsg({content:'传阅撤回失败！',icon:2});
                                pageObj.init();
                            }
                        }
                    });
                });
            })
        }
    })
    $.get('/code/GetDropDownBox',{CodeNos:'GWTYPE'},function (json) {
        var arrTwo=json.GWTYPE;
        var str='<option value=""><fmt:message code="hr.th.PleaseSelect"/></option>'
        for(var i=0;i<arrTwo.length;i++){
            str+='<option value="'+arrTwo[i].codeNo+'">'+arrTwo[i].codeName+'</option>'
        }
        $('[name="dispatchType"]').html(str)
    },'json')





</script>
</body>
</html>
